#!/bin/bash

set -u

prefix="$1"
shift

if ! aclocal -I $PWD > /dev/null 2>&1
then
    echo 'error: aclocal failed'
    exit 1
fi
autoconf
automake

if [[ $(uname) == 'Darwin' ]]; then
    LDFLAGS="-Xcompiler -F${prefix}/Library/Frameworks"
fi

./configure \
    --prefix="$prefix" \
    --with-slang="$prefix" \
    ${LDFLAGS:+LDFLAGS="$LDFLAGS"} PYTHON=$(type -p python2.4)
